/*function psbirdWindow(){
	var self=this;
	this.w_title='系统消息';
	this.w_window=$C('div',{'class':'psbirdWindow'});
	this.createHtml=function(){
		self.contentDiv=$C('div',{'class':'w_content'},self.innerDiv);
		return $C('table',{'cellPadding':'0','cellSpacing':'0'},$C('tbody',{},$C('tr',{},$C('td',{'class':'w_all'},$C('img',{'src':'images/window/lt_corner.gif'})),$C('td',{'class':'w_all t_bg'},$C('div',{'class':'w_title'},self.w_title)),$C('td',{'class':'w_all'},$C('img',{'src':'images/window/rt_corner.gif'}))),$C('tr',{},$C('td',{'class':'w_all l_bg'}),$C('td',{'class':'w_center'},self.contentDiv),$C('td',{'class':'w_all r_bg'})),$C('tr',{},$C('td',{'class':'w_all lrb_corner'}),$C('td',{'class':'w_all b_bg'}),$C('td',{'class':'w_all lrb_corner moveposition'}))));
	}
	this.closeWindow=function(){
		document.body.removeChild(self.block);
		document.body.removeChild(self.w_window);
		self=null;
	}
	this.showWindow=function(){
		var closeImg=$C('div',{'class':'closeimg'});
		eve.observe(closeImg,'mouseover',function(){closeImg.className='closeimg_over'});
		eve.observe(closeImg,'mouseout',function(){closeImg.className='closeimg'});
		eve.observe(closeImg,'click',self.closeWindow);
		self.block=$C('div',{'class':'shadow'});
		self.block.style.height=document.body.clientHeight+'px';
		self.w_window.appendChild($C('div',{'class':'closediv'},closeImg));
		self.w_window.appendChild(self.createHtml());
		self.contentDiv.style.width=self.w_width+'px';
		self.w_window.style.top=document.documentElement.scrollTop+100+'px';
		self.w_window.style.left='-1000px';
		document.body.appendChild(self.block);
		document.body.appendChild(self.w_window);
		var w_width=self.w_width||self.w_window.clientWidth;
		self.w_window.style.left=parseInt((document.body.clientWidth-w_width)/2)+'px';
		new psbirdDrag(self.w_window.getElementsByTagName('td')[1],self.w_window);
	}
}*/
function psbirdWindow(){}
psbirdWindow.prototype={
	w_window:null,
	//contentDiv:null;
	w_title:'系统窗口',
	init:function(){
		this.w_window=$C('div',{'class':'psbirdWindow'});
		var closeImg=$C('div',{'class':'closeimg'});
		eve.observe(closeImg,'mouseover',function(){closeImg.className='closeimg_over'});
		eve.observe(closeImg,'mouseout',function(){closeImg.className='closeimg'});
		eve.observe(closeImg,'click',this.closeWindow.bind(this));
		this.block=$C('div',{'class':'shadow'});
		//alert(getPosition($('foot')));
		this.block.style.height=getPosition($('foot'))[0]+'px';//整个主窗口被蒙上阴影
		this.w_window.appendChild($C('div',{'class':'closediv'},closeImg));
		this.w_window.appendChild(this.createHtml());
		this.contentDiv.style.width=this.w_width+'px';
		this.w_window.style.top=document.documentElement.scrollTop+100+'px';
		this.w_window.style.left='-1000px';
		document.body.appendChild(this.block);
		document.body.appendChild(this.w_window);
		var w_width=this.w_width||this.w_window.clientWidth;
		this.w_window.style.left=parseInt((document.body.clientWidth-w_width)/2)+'px';
		new psbirdDrag(this.w_window.getElementsByTagName('td')[1],this.w_window);
	},
	createHtml:function(){
		this.contentDiv=$C('div',{'class':'w_content'},this.innerDiv);
		return $C('table',{'cellPadding':'0','cellSpacing':'0'},$C('tbody',{},$C('tr',{},$C('td',{'class':'w_all'},$C('img',{'src':'images/window/lt_corner.gif'})),$C('td',{'class':'w_all t_bg'},$C('div',{'class':'w_title'},this.w_title)),$C('td',{'class':'w_all'},$C('img',{'src':'images/window/rt_corner.gif'}))),$C('tr',{},$C('td',{'class':'w_all l_bg'}),$C('td',{'class':'w_center'},this.contentDiv),$C('td',{'class':'w_all r_bg'})),$C('tr',{},$C('td',{'class':'w_all lrb_corner'}),$C('td',{'class':'w_all b_bg'}),$C('td',{'class':'w_all lrb_corner moveposition'}))));		
	},
	closeWindow:function(){
		document.body.removeChild(this.block);
		document.body.removeChild(this.w_window);
	}
};//*/
Function.prototype.bind=function(obj){//改变this
	var t=this;
	return function(){
		return t.apply(obj,arguments);
	}
}
var psbirdDialog=new Object();
psbirdDialog.warn=function(str,cssName,titlestr,w_width){
	var frame=new psbirdWindow();
	frame.w_width=w_width;
	frame.w_title=titlestr;
	frame.innerDiv=$C('table',{'width':'100%'},$C('tbody',{},$C('tr',{},$C('td',{'class':'w_imgtd '+cssName},str)),$C('tr',{},$C('td',{'class':'cen'},this.createButton('确定',frame.closeWindow.bind(frame),emptyFunc,frame)))));
	frame.init();	
}
psbirdDialog.alert=function(str,w_width){
	this.warn(str,'w_alert','系统提示',w_width||300);
}
psbirdDialog.error=function(str,w_width){
	this.warn(str,'w_error','出错了',w_width||300);
}
psbirdDialog.success=function(str,w_width){
	this.warn(str,'w_ok','成功了',w_width||300);
}
psbirdDialog.info=function(str,w_width){
	this.warn(str,'w_info','系统消息',w_width||300);
}
psbirdDialog.confirm=function(str,btnObj,w_width){
	var btnTd=$C('td',{'class':'cen'});
	var frame=new psbirdWindow();
	for(var btn in btnObj)
		btnTd.appendChild(this.createButton(btn,btnObj[btn],frame.closeWindow.bind(frame)));
	frame.w_width=w_width||400;
	frame.w_title='网页对话框';
	frame.innerDiv=$C('table',{'width':'100%'},$C('tbody',{},$C('tr',{},$C('td',{'class':'w_imgtd w_confirm'},str)),$C('tr',{},btnTd)));
	frame.init();
}
psbirdDialog.createButton=function(val,act,closeAct){
	var btn=$C('input',{'class':'btn','type':'button','value':val});
	eve.observe(btn,'mouseover',function(){btn.className='btn btn_over'});
	eve.observe(btn,'mouseout',function(){btn.className='btn';});
	eve.observe(btn,'click',act);
	eve.observe(btn,'click',closeAct);
	return btn;
}
psbirdDialog.html=function(inHtml,w_width,w_title){
	//var btnTd=$C('td',{'class':'cen'});
	var frame=new psbirdWindow();
	//frame.w_width=500;
	frame.w_width=w_width||500;
	frame.w_title=w_title||'系统窗口';
	frame.innerDiv=$C('table',{'width':'100%'},$C('tbody',{},$C('tr',{},$C('td',{},inHtml))));
	frame.init();
	return frame.closeWindow.bind(frame);
}
function psbirdDrag(hotArea,wholeArea){
	var self=this;
	this.divX=0;
	this.divY=0;
	this.mouseX=0;
	this.mouseY=0;
	this.initialize=function(e){
		var divPosition=self.getPosition(wholeArea);
		self.divX=divPosition[1];
		self.divY=divPosition[0];
		self.mouseX=e.clientX;
		self.mouseY=e.clientY;
		eve.observe(document.body,'mousemove',self.drag);
		eve.observe(document.body,'mouseup',self.stopDrag);
		eve.observe(document.body,'select',self.noselect);
	}
	this.drag=function(e){
		var mx=e.clientX-self.mouseX;
		var my=e.clientY-self.mouseY;
		wholeArea.style.left=self.divX+mx+'px';
		wholeArea.style.top=self.divY+my+'px';
		self.divX+=mx;
		self.divY+=my;
		self.mouseX+=mx;
		self.mouseY+=my;
	}
	this.stopDrag=function(){
		eve.stopObserve(document.body,'mousemove',self.drag);
		eve.stopObserve(document.body,'mouseup',self.stopDrag);
		eve.stopObserve(document.body,'select',self.noselect);
	}
	this.getPosition=function(obj){
		return [obj.offsetTop,obj.offsetLeft];
	}
	this.noselect=function(){
		document.selection.empty();
	}
	eve.observe(hotArea,'mousedown',self.initialize);
}